from time import sleep

from thorx.env import ThorXEnvPyBullet


env = ThorXEnvPyBullet(
    gui=True,
    depth=True,
    mask=True,
    absolute=True,
    fps=0.5,
    manual=True,
)

steps_max = env.steps_max
step = 0
reward_total = 0
while not env.terminated:
    action = env.action_space.sample()
    # print(f"DEBUG: action = {action}")
    observation, reward, terminated, truncated, _ = env.step(action=action)
    reward_total += reward
    # sleep(2)  # 2 seconds
    step += 1
    if step >= steps_max:
        print(f"Reward (episode) = {reward_total}")
        reward_total = 0
        step = 0
        # result = env.reset()
        # print(f"Reset: {result}")
print(f"Exit normally: env terminated = {env.terminated}...")
